package com.atguigu.flink.day05;

import com.atguigu.flink.bean.WaterSensor;
import com.atguigu.flink.func.WaterSensorMapFunction;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.windowing.assigners.*;
import org.apache.flink.streaming.api.windowing.time.Time;

/**
 * @author Felix
 * @date 2024/8/14
 * 该案例演示了窗口分配器
 */
public class Flink05_Window_Assi {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        SingleOutputStreamOperator<WaterSensor> wsDS = env
                .socketTextStream("hadoop102", 8888)
                .map(new WaterSensorMapFunction());

        wsDS
                .keyBy(WaterSensor::getId);
                //滚动处理时间窗口
                //.window(TumblingProcessingTimeWindows.of(Time.seconds(10)))
                //滑动处理时间窗口
                //.window(SlidingProcessingTimeWindows.of(Time.seconds(10),Time.seconds(2)))
                //处理时间会话窗口
                //.window(ProcessingTimeSessionWindows.withGap(Time.seconds(10)))
                //滚动事件时间窗口
                //.window(TumblingEventTimeWindows.of(Time.seconds(10)))
                //滑动事件时间窗口
                //.window(SlidingEventTimeWindows.of(Time.seconds(10),Time.seconds(2)))
                //事件时间会话窗口
                //.window(EventTimeSessionWindows.withGap(Time.seconds(10)))

                //滚动计数窗口
                //.countWindow(10)
                //滑动计数窗口
                //.countWindow(10,2)

                //全局窗口
                //.window(GlobalWindows.create())


                //.window()

    }
}
